<template>
    <div>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/main' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
      </el-breadcrumb>
      <el-card class="box-card">
        <el-table :data="data" style="width: 100%" border>
          <el-table-column type="index" label="#" width="50px"> </el-table-column>
          <el-table-column prop="authName" label="权限名称" width="378px"> </el-table-column>
          <el-table-column prop="path" label="路径" width="377px"> </el-table-column>
          <el-table-column label="权限等级" width="377px">
            <template slot-scope="{row:{level}}"> 
              <el-tag v-if="level==0">一级</el-tag>
              <el-tag v-else-if="level==1" type="success">二级</el-tag>
              <el-tag v-else-if="level==2" type="warning">三级</el-tag>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </div>
  </template>
  <script>
  export default {
    data() {
      return {
        tablelist: [],
        p: 1,
        total: 5,
        data: [],
      };
    },
    methods: {
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
      async list(){
          let {data:{data,meta}} = await this.$http.get(`rights/list`)
          if(meta.status!==200) return this.$message.error("获取权限列表失败")
          this.data=data
          console.log(data);
      }
    },
    created(){
      this.list()
    }
  };
  </script>